var foundDiplomacy = 0;
var foundAlliance = 0;
var ret='';
var alliance='';
var server='';
server=location.pathname.split('/');
server=server[1];
var a_obj = document.getElementsByTagName("div");
for (var i = 0; i < a_obj.length; i++) {
    if (a_obj[i].innerText.substring(0, 6) == "Allies") {foundDiplomacy = 1;}
    if (foundDiplomacy && a_obj[i].innerHTML.replace(/<(.)*>/g, "").length>0) {ret+=','+a_obj[i].innerHTML.replace(/<(.)*>/g, "");}
    if (a_obj[i].style.left == "5px" && a_obj[i].style.top == "58px" && foundAlliance==0) {alliance=a_obj[i].innerText;foundAlliance=1;}
}

if (foundDiplomacy) {
    var allies=ret.split('Allies,');
    allies=allies[1].split(',Non-Aggression Pact (NAP),');
    allies=allies[0];

    var naps=ret.split(',Non-Aggression Pact (NAP),');
    naps=naps[1].split(',Enemy,');
    naps=naps[0];

    var enemies=ret.split(',Enemy,');
    enemies=enemies[1].split(',ALLIANCE');
    enemies=enemies[0];

    window.open('http://tiberium-uaf.blogspot.com/?v=2&server='+server+'&self='+alliance+'&allies='+allies+'&naps='+naps+'&enemies='+enemies);
    //alert("Self="+alliance+"\nAllies="+allies+"\n\nNAPs="+naps+"\n\nEnemies="+enemies);
} else {
    alert('Open "Diplomacy" tab under "Alliance" and try again');
}